<?php
// src/Salgamos/BackendBundle/DataFixtures/ORM/LoadCategoryData.php
namespace Salgamos\BackendBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Salgamos\BackendBundle\Entity\Category;
use Salgamos\BackendBundle\Entity\Subcategory;

class LoadCategoryData extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * {@inheritDoc}
     */
    public function load(ObjectManager $manager)
    {
        $category = new Category();
        $category->setName('Gastronomía');
        $category->setAlias('gastronomia');
        $category->setDescription('descripcion gastronomia');
        $manager->persist($category);
        $subcategory = new Subcategory();
        $subcategory->setAlias('default');
        $subcategory->setName('Default');
        $subcategory->setDescription('descripcion default');
        $subcategory->setCategory($category);
        $manager->persist($subcategory);
        $this->addReference('subcategory1', $subcategory);
            
        
        $category = new Category();
        $category->setName('After Ofice');
        $category->setAlias('after_ofice');
        $category->setDescription('descripcion after ofice');
        $manager->persist($category);
        $subcategory = new Subcategory();
        $subcategory->setAlias('default');
        $subcategory->setName('Default');
        $subcategory->setDescription('descripcion default');
        $subcategory->setCategory($category);
        $manager->persist($subcategory);
        $this->addReference('subcategory2', $subcategory);
        
        $category = new Category();
        $category->setName('Sport');
        $category->setAlias('sport');
        $category->setDescription('descripcion sport');
        $manager->persist($category);
        $subcategory = new Subcategory();
        $subcategory->setAlias('default');
        $subcategory->setName('Default');
        $subcategory->setDescription('descripcion default');
        $subcategory->setCategory($category);
        $manager->persist($subcategory);
        $this->addReference('subcategory3', $subcategory);
        
        $category = new Category();
        $category->setName('Tour');
        $category->setAlias('tour');
        $category->setDescription('descripcion tour');
        $manager->persist($category);
        $subcategory = new Subcategory();
        $subcategory->setAlias('default');
        $subcategory->setName('Default');
        $subcategory->setDescription('descripcion default');
        $subcategory->setCategory($category);
        $manager->persist($subcategory);
        $this->addReference('subcategory4', $subcategory);
        
        $category = new Category();
        $category->setName('Entretainment');
        $category->setAlias('entretainment');
        $category->setDescription('descripcion entretainment');
        $manager->persist($category);
        $subcategory = new Subcategory();
        $subcategory->setAlias('default');
        $subcategory->setName('Default');
        $subcategory->setDescription('descripcion default');
        $subcategory->setCategory($category);
        $manager->persist($subcategory);
        $this->addReference('subcategory5', $subcategory);
        
        $category = new Category();
        $category->setName('Escapada');
        $category->setAlias('escapada');
        $category->setDescription('descripcion escapada');
        $manager->persist($category);
        $subcategory = new Subcategory();
        $subcategory->setAlias('default');
        $subcategory->setName('Default');
        $subcategory->setDescription('descripcion default');
        $subcategory->setCategory($category);
        $manager->persist($subcategory);
        $this->addReference('subcategory6', $subcategory);
        
        $manager->flush();

    }

    /**
     * {@inheritDoc}
     */
    public function getOrder()
    {
        return 1; // the order in which fixtures will be loaded
    }
}
?>
